package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * [万灵山海,万物归元]
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(20)
public class AWanlinGameStrategy extends BaseGameStrategy {
    public static final String URL = "http://111.170.174.196:30581/gmht/user/gmquery.php";

    /**
     * type: charge
     * checknum: diyao88
     * uid: 风云精品
     * num: 123
     * num2: 666
     * qu: 1
     * @param item
     * @return
     */
    @GongnengMethod(2001)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type", "charge");
        params.add("checknum", "diyao88");
        params.add("qu", "1");

        params.add("num", item.number);
        params.add("num2", item.itemId);
        params.add("uid", item.uid);
        return RestTemplateUtil.sendPostFormAndGetJsonKey(URL, params, "info");
    }

    /**
     * type: mail
     * checknum: diyao88
     * uid: 风云精品
     * item: 26414
     * num: 12
     * qu: 1
     * @param item
     * @return
     */
    @GongnengMethod(2002)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type", "mail");
        params.add("checknum", "diyao88");
        params.add("qu", "1");

        params.add("num", item.number);
        params.add("item", item.itemId);
        params.add("uid", item.uid);
        return RestTemplateUtil.sendPostFormAndGetJsonKey(URL, params, "info");
    }

    @GongnengMethod(2003)
    public String day(SendItem item) {
        return mail(item);
    }


    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }
}

